{include file="default/base/seller_top" /} 
<div class="seller_main w1200">
    {include file="default/base/seller_left" /}
    <div class="seller_right">
        



<div class="seller_items">
    {include file="default/base/seller_items" /}
</div>
{if isset($edit_goods_sign)}
{else /}
      <ul class="add-goods-step">
        <li><i class="icon iconfont">&#xe600;</i>
          <h6>STEP.1</h6>
          <h2>{$Think.lang.select_category}</h2>
          <i class="arrow iconfont">&#xe687;</i></li>
        <li><i class="icon iconfont">&#xe731;</i>
          <h6>STEP.2</h6>
          <h2>填写基本信息</h2>
          <i class="arrow iconfont">&#xe687;</i></li>
        <li><i class="icon iconfont">&#xe731;</i>
          <h6>STEP.3</h6>
          <h2>完善商品信息</h2>
          <i class="arrow iconfont">&#xe687;</i></li>
        <li  class="current"><i class="icon iconfont">&#xe6a2;</i>
          <h6>STEP.4</h6>
          <h2>{$Think.lang.store_goods_index_upload_goods_pic}</h2>
      </ul>
{/if}
<form method="post" id="goods_image" action="<?php if (isset($edit_goods_sign)) { echo url('sellergoodsinfomessage/edit_save_image'); } else { echo url('Sellergoodsadd/save_image');}?>"  >
  <input type="hidden" name="commonid" value="{$commonid}">
  {notempty name="value_array"}
  <div class="dssc-form-goods-pic">
    <div class="container">
      {foreach name="value_array" item="value"}
      <div class="dssc-goodspic-list">
        <div class="title">
          </div>
        <ul dstype="ul{$value.spvalue_id}">
          <?php for ($i = 0; $i < 10; $i++) {?>
          <li class="dssc-goodspic-upload">
            <div class="upload-thumb"><img src="<?php if(isset($img[$value['spvalue_id']][$i]['goodsimage_url'])&&!empty($img[$value['spvalue_id']][$i]['goodsimage_url'])){echo $http_name.'/'.$img[$value['spvalue_id']][$i]['goodsimage_url'];}else{echo  goods_cthumb('', 240);}?>" dstype="file_<?php echo $value['spvalue_id'] . $i;?>">
              <input type="hidden" name="img[<?php echo $value['spvalue_id'];?>][<?php echo $i;?>][name]" value="<?php if(isset($img[$value['spvalue_id']][$i]['goodsimage_url'])){echo $img[$value['spvalue_id']][$i]['goodsimage_url'];}?>" dstype="file_<?php echo $value['spvalue_id'] . $i;?>">
            </div>
            <div class="show-default<?php if (isset($img[$value['spvalue_id']][$i]['goodsimage_url']) && $img[$value['spvalue_id']][$i]['goodsimage_isdefault'] == 1) {echo ' selected';}?>" dstype="file_<?php echo $value['spvalue_id'] . $i;?>">
              <p><i class="iconfont">&#xe64d;</i>{$Think.lang.default_main_map}
                <input type="hidden" name="img[<?php echo $value['spvalue_id'];?>][<?php echo $i;?>][default]" value="<?php if ( isset($img[$value['spvalue_id']][$i]['goodsimage_url']) && $img[$value['spvalue_id']][$i]['goodsimage_isdefault'] == 1) {echo '1';}else{echo '0';}?>">
              </p><a href="javascript:void(0)" dstype="del" class="del" title="{$Think.lang.remove}">X</a>
            </div>
            
            <div class="dssc-upload-btn"><a href="javascript:void(0);"><span><input type="file" hidefocus="true" size="1" class="input-file" name="file_<?php echo $value['spvalue_id'] . $i;?>" id="file_<?php echo $value['spvalue_id'] . $i;?>"></span><p><i class="iconfont">&#xe733;</i>{$Think.lang.ds_common_button_upload}</p>
              </a>
            </div>
          </li>
          <?php }?>
        </ul>
        <div class="dssc-select-album">
          <a href="javascript:void(0);" dstype="close_album" class="dssc-btn ml5" style="display: none;"><i class=" iconfont">&#xe67a;</i>{$Think.lang.close_album}</a>
        </div>
        <div dstype="album-{$value.spvalue_id}"></div>
      </div>
      {/foreach}
    </div>
    <div class="sidebar"><div class="alert alert-info alert-block" id="uploadHelp">
    <div class="faq-img"></div>
    <h4>{$Think.lang.upload_request}：</h4><ul>
    <li>{$Think.lang.upload_information1}<?php echo intval(config('image_max_filesize'))/1024;?>{$Think.lang.upload_information2}</li>
    <li>{$Think.lang.upload_information3}</li>
    <li>{$Think.lang.upload_information4}</li>
    <li>{$Think.lang.upload_information5}</li>
    <li>{$Think.lang.upload_information6}</li>
    <li>{$Think.lang.upload_information7}</li>
    </ul><h4>{$Think.lang.advice}</h4><ul><li>{$Think.lang.upload_advice1}</li><li>{$Think.lang.upload_advice2}</li></ul></div></div>
  </div>
  {/notempty}
  <div class="bottom tc hr32">
    <input type="hidden" name="add_type" id="add_type" value="">
    <input type="button" class="dssc-btn dssc-btn-acidblue"  style="margin-top: 10px; width: 260px;margin-left: -628px;height: 40px;font-size: 16px;" value="暂存商品信息" id="zan_submit" />
    <input type="button" class="submit" lay-filter="formDemo"  style="margin-left: 369px;margin-top: -39px;" value="<?php if (isset($edit_goods_sign)) { echo lang('ds_submit'); } else { ?>{$Think.lang.store_goods_add_next}，提交商品进行审核<?php }?>" id='button_submit' />

  </div>
</form>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/ajaxfileupload.js" charset="utf-8"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/jquery.ajaxContent.pack.js" type="text/javascript"></script>
<script src="{$Think.HOME_SITE_ROOT}/js/sellergoods_add_step3.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/layui/layui.js"></script>

<!-- <script>
//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    alert(111);
    layer.msg(JSON.stringify(data.field));
    return false;
  });
});
</script> -->


<script>

var DEFAULT_GOODS_IMAGE = "{:goods_cthumb('', 240)}";
$(function(){
    <?php if (isset($edit_goods_sign)){?>
    $(function(){
        $('#goods_image').validate({
            submitHandler:function(form){
                ds_ajaxpost('goods_image','default');
            },
            rules : {
            },
            messages : {
            }
        });
    });
    <?php }?>
    /* ajax打开图片空间 */
    <?php foreach ($value_array as $value) {?>
    $('a[dstype="select-{$value.spvalue_id}"]').ajaxContent({
        event:'click', //mouseover
        loaderType:"img",
        loadingMsg:'{$Think.HOME_SITE_ROOT}/images/loading.gif',
        target:'div[dstype="album-{$value.spvalue_id}"]'
    }).click(function(){
        $(this).hide();
        $(this).next().show();
    });
    <?php }?>
});
</script>

<script type="text/javascript">
         //提交审核
          $("#button_submit").click(function(){
             var url = $('form').attr('action');
            $('#add_type').val('1');
             $.ajax({
              cache: true,
              type: "POST",
              url:url,
              data:$('#goods_image').serialize(),// 你的formid
              async: false,
              error: function(request) {
                  alert("Connection error");
              },
              success: function(data) {
               // alert(data);return false;
                if(data.code==0){
                 layer.msg(data.msg);
                  location.href=data.url;return false;
                }else if(data.code == -1){
                  layer.msg(data.msg);return false;
                }else{
                 layer.msg('添加成功');
                 location.href=data.url;return false;
                }
              }
          });
          });
              //暂存不发布
              $("#zan_submit").click(function(){
                var url = $('form').attr('action');
                $('#add_type').val('2');
                $.ajax({
                  cache: true,
                  type: "POST",
                  url:url,
                  data:$('#goods_image').serialize(),// 你的formid
                  async: false,
                  error: function(request) {
                    alert("Connection error");
                  },
                  success: function(data) {
                    // alert(data);return false;
                    if(data.code==0){
                      layer.msg(data.msg);
                      location.href=data.url;return false;
                    }else{
                      layer.msg('添加成功');
                      location.href=data.url;return false;
                    }
                  }
                });
              });
 
</script>



    </div>
</div>
{include file="default/base/mall_footer" /}